<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
        >
<ui:composition template="/templates/layout2.xhtml">
<ui:define name="title">Configuración</ui:define>
<ui:define name="content">
    <h:panelGrid columns="2" columnClasses="subdivisionRight,subdivisionRight">
        <h:panelGrid columns="3" width="400" columnClasses="subdivisionLeft,subdivisionCenter,subdivisionRight">
            <p:panel id="criterios" header="Parametros de Configuración" toggleable="true" toggleSpeed="250">
                <h:form id="createForm" prependId="false">
                    <h:panelGrid id="filtroPanelGrid" columns="3" styleClass="dialog" cellpadding="5">
                        <p:spacer/>
                        <h:outputLabel styleClass="columna" value="Directorio Base"/>
                        <p:inputText maxlength="255"
                                     value="#{clienteBean.dir}"
                                     validatorMessage="Max length is 255" style="width:200px;">
                            <f:validateLength maximum="255"/>
                        </p:inputText>
                        <p:spacer/>
                        <h:outputLabel styleClass="columna" value="URL EBIZ"/>
                        <p:inputText maxlength="255"
                                     value="#{clienteBean.urlEbiz}"
                                     validatorMessage="Max length is 255" style="width:300px;">
                            <f:validateLength maximum="255"/>
                        </p:inputText>
                        <p:spacer/>
                        <h:outputLabel styleClass="columna" value="URL Emisor"/>
                        <p:inputText maxlength="255"
                                     value="#{clienteBean.urlEmisor}"
                                     validatorMessage="Max length is 255" style="width:300px;">
                            <f:validateLength maximum="255"/>
                        </p:inputText>
                        <p:spacer/>
                        <h:outputLabel styleClass="columna" value="FTP Host"/>
                        <p:inputText maxlength="255"
                                     value="#{clienteBean.ftpHost}"
                                     validatorMessage="Max length is 255" style="width:80px;">
                            <f:validateLength maximum="255"/>
                        </p:inputText>
                        <p:spacer/>
                        <h:outputLabel styleClass="columna" value="FTP Port"/>
                        <p:inputText maxlength="255"
                                     value="#{clienteBean.ftpPort}"
                                     validatorMessage="Max length is 255" style="width:80px;">
                            <f:validateLength maximum="255"/>
                        </p:inputText>
                        <p:spacer/>
                        <h:outputLabel styleClass="columna" value="Tiempo Máximo - Declarar (Horas)"/>
                        <p:inputText maxlength="255"
                                     value="#{clienteBean.tiempoValido}"
                                     validatorMessage="Max length is 255" style="width:80px;">
                            <f:validateLength maximum="255"/>
                        </p:inputText>
                        <p:spacer/>
                        <h:outputLabel styleClass="columna" value="Tipo Sincronización"/>
                        <p:selectOneMenu id="rolEmpresarial" value="#{clienteBean.tipoSincronizacion}"
                                         effect="fade"
                                         styleClass="combo">
                            <f:selectItem itemLabel="Normal" itemValue="01NORMAL"/>
                            <f:selectItem itemLabel="Sólo Cliente" itemValue="02SOLOCLIENTE"/>
                            <f:selectItem itemLabel="Solo Ebiz" itemValue="03SOLOEBIZ"/>
                        </p:selectOneMenu>

                    </h:panelGrid>

                        <h:panelGrid id="filtroPanelGridEbiz" columns="3" styleClass="dialog" cellpadding="5" rendered="#{clienteBean.esEbiz}">
                            <p:spacer/>
                            <h:outputLabel styleClass="columna" value="Email Host"/>
                            <p:inputText maxlength="255"
                                         value="#{clienteBean.emailHost}"
                                         validatorMessage="Max length is 255" style="width:200px;">
                                <f:validateLength maximum="255"/>
                            </p:inputText>
                            <p:spacer/>
                            <h:outputLabel styleClass="columna" value="Email Port"/>
                            <p:inputText maxlength="255"
                                         value="#{clienteBean.emailPort}"
                                         validatorMessage="Max length is 255" style="width:300px;">
                                <f:validateLength maximum="255"/>
                            </p:inputText>
                            <p:spacer/>
                            <h:outputLabel styleClass="columna" value="Email From"/>
                            <p:inputText maxlength="255"
                                         value="#{clienteBean.emailFrom}"
                                         validatorMessage="Max length is 255" style="width:300px;">
                                <f:validateLength maximum="255"/>
                            </p:inputText>
                            <p:spacer/>
                            <h:outputLabel styleClass="columna" value="Email Usuario"/>
                            <p:inputText maxlength="255"
                                         value="#{clienteBean.emailUserName}"
                                         validatorMessage="Max length is 255" style="width:80px;">
                                <f:validateLength maximum="255"/>
                            </p:inputText>
                            <p:spacer/>
                            <h:outputLabel styleClass="columna" value="Email Clave"/>
                            <p:inputText maxlength="255"
                                         value="#{clienteBean.emailPassword}"
                                         validatorMessage="Max length is 255" style="width:80px;">
                                <f:validateLength maximum="255"/>
                            </p:inputText>
                            <p:spacer/>
                            <h:outputLabel styleClass="columna" value="FTP Host"/>
                            <p:inputText maxlength="255"
                                         value="#{clienteBean.ftpHost}"
                                         validatorMessage="Max length is 255" style="width:80px;">
                                <f:validateLength maximum="255"/>
                            </p:inputText>
                            <p:spacer/>
                            <h:outputLabel styleClass="columna" value="FTP Port"/>
                            <p:inputText maxlength="255"
                                         value="#{clienteBean.ftpPort}"
                                         validatorMessage="Max length is 255" style="width:80px;">
                                <f:validateLength maximum="255"/>
                            </p:inputText>
                            <p:spacer/>

                        </h:panelGrid>

                    <h:panelGrid columns="1">
                        <p:commandButton value="Grabar" icon="ui-icon-document"
                                         actionListener="#{clienteBean.onPersistGeneral}" async="false"
                                         ajax="true" update="createForm messages"/>
                    </h:panelGrid>
                </h:form>
            </p:panel>
            <p:spacer/>

        </h:panelGrid>
        <h:panelGrid columns="1" width="500" columnClasses="subdivisionRight">
            <p:panel id="criteriosEmisor" header="Emisores" toggleable="true" toggleSpeed="250">
                <h:form prependId="false">
                    <p:toolbar styleClass="ebiz-toolbar">
                        <p:toolbarGroup align="left">
                            <p:commandButton value="Nuevo" icon="ui-icon-document" ajax="true"
                                             actionListener="#{clienteBean.newDialogOpen}" update="createDialog"
                                             oncomplete="createDialog.show();"/>

                            <p:commandButton id="editButton" value="Editar" ajax="true"
                                             actionListener="#{clienteBean.onEditDialogOpen}"
                                             update="createDialog"
                                             title="Editar">
                            </p:commandButton>
                            <p:commandButton id="probarButton" value="Probar" ajax="true" global="true"
                                             actionListener="#{clienteBean.onFirmaFactura}" update="createForm messages"
                                             title="Probar">
                            </p:commandButton>
                        </p:toolbarGroup>
                    </p:toolbar>

                    <p:panel id="data" toggleable="false" toggleSpeed="250" styleClass="gridContent">
                        <f:facet name="header">
                            <h:outputText value="Lista de emisores"/>
                        </f:facet>
                        <h:outputFormat id="noRecordsFound" value="No existen registros"
                                        rendered="#{empty clienteBean.allEmisores}">
                        </h:outputFormat>
                        <p:dataTable id="list" value="#{clienteBean.allEmisores}" var="emisor"
                                     rowKey="#{emisor.idEmisor}"
                                     rendered="#{not empty clienteBean.allEmisores}" resizableColumns="false"
                                     paginator="true"
                                     selection="#{clienteBean.bean}" selectionMode="single"
                                     paginatorTemplate=" {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     rowsPerPageTemplate="5,10,25,50" rows="10">
                            <p:column sortBy="#{emisor.idEmisor}" styleClass="columnLeftTopClass">
                                <f:facet name="header">
                                    <h:outputText value="RUC"/>
                                </f:facet>
                                <h:outputText value="#{emisor.idEmisor}"/>
                            </p:column>

                            <p:column sortBy="#{emisor.usuarioebiz}" styleClass="columnLeftTopClass">
                                <f:facet name="header">
                                    <h:outputText value="Usuario EBIZ"/>
                                </f:facet>
                                <h:outputText value="#{emisor.usuarioebiz}"/>
                            </p:column>

                            <p:column sortBy="#{emisor.usuariosol}" styleClass="columnLeftTopClass">
                                <f:facet name="header">
                                    <h:outputText value="Usuario SOL"/>
                                </f:facet>
                                <h:outputText value="#{emisor.usuariosol}"/>
                            </p:column>
                        </p:dataTable>
                    </p:panel>
                </h:form>
            </p:panel>
        </h:panelGrid>
    </h:panelGrid>


    <p:dialog id="dlgMessageErrors"
              header="Información" appendTo="@(body)"
              modal="true" widgetVar="dlgMessageErrors" resizable="false"
              dynamic="true" width="250">
        <h:panelGrid id="pnlMessagesError" columns="1"
                     styleClass="dialog">
            <h:outputText value="#{clienteBean.errores}"/>
        </h:panelGrid>
        <br/>
        <p:commandButton value="Aceptar"
                         onclick="dlgMessageErrors.hide()" type="button"/>
    </p:dialog>
</ui:define>
<ui:define name="modal">
    <p:dialog id="createDialog" header="Crear Emisor" modal="true" widgetVar="createDialog"
              resizable="true" maximizable="true"
              showEffect="fade" hideEffect="fade">
        <p:ajax event="close" update="data" listener="#{clienteBean.handleDialogClose}"/>
        <h:form id="createFormDialog" enctype="multipart/form-data">
            <h:panelGrid id="createPanelGrid" columns="3" styleClass="dialog" columnClasses="col1, col2, col3">

                <h:panelGrid id="filtroPanelGrid" columns="3" styleClass="dialog" cellpadding="5">

                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="RUC Emisor"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.idEmisor}"
                                 validatorMessage="Tamaño máximo es 255" style="width:100px;">
                        <f:validateLength maximum="15"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Usuario EBIZ"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.usuarioebiz}"
                                 validatorMessage="Tamaño máximo es 255" style="width:100px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Clave EBIZ"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.contraseniaebizEdit}"
                                 validatorMessage="Max length is 255" style="width:100px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Usuario FTP"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.usuarioFtp}"
                                 validatorMessage="Tamaño máximo es 255" style="width:100px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Clave FTP"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.contraseniaFtp}"
                                 validatorMessage="Max length is 255" style="width:100px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Nombre Logo"/>
                    <p:inputText maxlength="255" alt="Por ejmplo logo.png"
                                 value="#{clienteBean.bean.nombreLogo}"
                                 validatorMessage="Max length is 255" style="width:100px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Número de Resolución"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.numeroresolucion}"
                                 validatorMessage="Max length is 255" style="width:100px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Usuario SOL"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.usuariosol}"
                                 validatorMessage="Max length is 255" style="width:150px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Clave SOL"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.claveSolEdit}"
                                 validatorMessage="Max length is 255" style="width:100px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Key Store File"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.rutacertificado}"
                                 validatorMessage="Max length is 255" style="width:200px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Key Store Password"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.contraseniacertificado}"
                                 validatorMessage="Max length is 255" style="width:80px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Private Key Alias"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.privateKeyAlias}"
                                 validatorMessage="Max length is 255" style="width:250px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                    <p:spacer/>
                    <h:outputLabel styleClass="columna" value="Private Key Password"/>
                    <p:inputText maxlength="255"
                                 value="#{clienteBean.bean.privateKeyPasswordEdit}"
                                 validatorMessage="Max length is 255" style="width:80px;">
                        <f:validateLength maximum="255"/>
                    </p:inputText>
                </h:panelGrid>
            </h:panelGrid>

            <p:commandButton value="Guardar" actionListener="#{clienteBean.onPersist}" ajax="true"
                             update="createPanelGrid data messages">
                <f:attribute name="dialogName" value="createDialog"/>
            </p:commandButton>
            <p:commandButton value="Cancelar" onclick="createDialog.hide()" type="button"
                             update="createPanelGrid"/>
        </h:form>
    </p:dialog>


    <p:confirmDialog id="deleteDialog" widgetVar="deleteDialog" message="¿Está seguro que desea eliminar este registro?"
                     appendTo="@(body)"
                     showEffect="fade" hideEffect="fade" header="Confirmar eliminación"
                     severity="alarm">
        <h:form id="deleteForm">
            <p:commandButton value="Sí" action="#{clienteBean.deleteAction}" update="data"
                             oncomplete="deleteDialog.hide()"/>
            <p:commandButton value="No" onclick="deleteDialog.hide()" type="button"/>
        </h:form>
    </p:confirmDialog>
</ui:define>
</ui:composition>
</html>